package com.lzy.product.service.impl;

import com.lzy.framework.core.utils.DozerUtils;
import com.lzy.product.dao.AgentProtocolProductMapperExt;
import com.lzy.product.dtos.agent.AgentProtocolProductDto;
import com.lzy.product.entity.AgentProtocolProduct;
import com.lzy.product.service.AgentProtocolProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class AgentProtocolProductServiceImpl implements AgentProtocolProductService {

    @Autowired
    private AgentProtocolProductMapperExt agentProtocolProductMapperExt;

    @Override
    public Long insert(AgentProtocolProductDto dto) {
        AgentProtocolProduct agentProtocolProduct = DozerUtils.map(dto, AgentProtocolProduct.class);
        return agentProtocolProductMapperExt.insertSelective(agentProtocolProduct) > 0 ? agentProtocolProduct.getId() : 0;
    }

    @Override
    public Boolean update(AgentProtocolProductDto dto) {
        return agentProtocolProductMapperExt.updateByPrimaryKeySelective(DozerUtils.map(dto, AgentProtocolProduct.class)) > 0;
    }

    @Override
    public Boolean delete(Long id) {
        return null;
    }

    @Override
    public Boolean remove(Long id) {
        return null;
    }

    @Override
    public AgentProtocolProductDto findById(Long id) {
        return DozerUtils.map(agentProtocolProductMapperExt.selectByPrimaryKey(id), AgentProtocolProductDto.class);
    }

    @Override
    public List<AgentProtocolProductDto> query(AgentProtocolProductDto dto) {
        return null;
    }

    @Override
    public List<AgentProtocolProductDto> selectByProtocolId(Long protocolId) {
        return agentProtocolProductMapperExt.selectByProtocolId(protocolId);
    }

    @Override
    public List<AgentProtocolProductDto> selectByProductId(Long productId) {
        return agentProtocolProductMapperExt.selectByProductId(productId);
    }

    @Override
    public Boolean deleteByProtocolId(Long protocolId) {
        return agentProtocolProductMapperExt.deleteByProtocolId(protocolId);
    }
}
